﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
using System.Data.Common;

namespace MsgSender
{
    public static class DBHelper
    {
        private static string _connectstring = "Data Source =" + AppDomain.CurrentDomain.BaseDirectory+AppSetting.AppSettings.DBConnnectString;

        /// <summary>
        /// 执行数据库操作(新增、更新或删除)
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(SQLiteCommand cmd)
        {
            return SQLite.SQLiteHelper.ExecuteNonQuery(_connectstring, cmd);
        }

        /// <summary>
        /// 执行数据库查询，返回DataSet对象
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataSet(SQLiteCommand cmd)
        {
            return SQLite.SQLiteHelper.ExecuteDataSet(_connectstring,cmd);
        }

        public static DbDataReader ExecuteReader(SQLiteCommand cmd)
        {
            return SQLite.SQLiteHelper.ExecuteReader(_connectstring, cmd);
        }

    }
}
